Skip to main content

Integrating Sponsored Prompts

This guide provides comprehensive instructions on integrating sponsored prompts within your conversational AI. It covers essential aspects such as environment modes, tracking and more.

Production vs. Sandbox Mode

Important: When integrating sponsored prompts, it’s crucial to distinguish between production and sandbox (non-production) environments. - In sandbox mode (production=False), ads are returned for testing purposes but are not counted for monetization. - In production mode (production=True), ads are live and contribute to monetization. Always ensure production=True is used only in your live production environment. For all testing and development, set production=False.

Using Sponsored Prompts

Sponsored prompts can be incorporated into your AI conversations in two primary ways: as an initial opener or as contextual follow-up questions.

Starting Conversations with Sponsored Openers

You can use the sponsored question endpoint to generate an “opener” – a question to initiate a conversation.Key Points:
  • No Context Needed: Simply call the endpoint without any prior conversational context.
  • Tailored for Your App: The API will provide a sponsored question suitable for your application, yet conversation-agnostic.
  • Unaffected by conversationalOffset and adFrequency and force: These parameters do not influence the behavior of opener prompts.
Code Example:

Handling Click Tracking

To ensure accurate monetization and analytics, you must track user clicks on sponsored messages.
1

Receive the Token

The sponsored prompts endpoint (for both openers and follow-ups) returns a unique token along with the sponsored question. Store this token.
2

Detect User Interaction

When a user clicks or taps on the displayed sponsored question.
3

Send Click Confirmation

Immediately send a POST request to the /api/v1/prompt/click/ endpoint. Include the token (received in Step 1) in the JSON body of your request.
4

Receive Reward Confirmation

A successful POST request to the click tracking endpoint will record the click and associate the reward.
Code Example for Click Tracking:

Best Practices

1. Use Metadata for Better Targeting

2. Control Ad Frequency (Only for follow-up)

Use adFrequencyLimit and conversationOffset to prevent ad fatigue:

3. Managing Response Delays

In rare cases, the Thrads API response might be delayed (typically between 0.5-0.8 seconds). During this time, the user may begin typing a new question. We recommend to have some logic in place to suppress the ad render if that arrives late. For detailed API specifications, please refer to the API Reference for Sponsored Prompts.