Skip to content

Direqt | Embed

To seamlessly integrate your Direqt chatbot into your website, you can use the Direqt Embed feature. This allows chatbot developers to add their chatbot within the flow of their webpage, providing an integrated user experience.

Locating Necessary Credentials

Before you can embed your chatbot, there are two IDs needed for everything work properly.

Publisher ID

The publisher ID is a unique identifier for your Direqt account. It is used to identify your account when you make API calls to Direqt. Your publisher ID is synonymous with your network ID, and can be found in the Direqt console under the "Settings" tab.

Locating Network ID

Bot ID

The bot ID is a unique identifier for your chatbot. It is used to identity which chatbot to display within your embed. Your bot ID can be found in the Direqt console within the "Chatbot Settings" tab.

Locating Chatbot ID

Adding The Embed Script

To begin, you need to include the Direqt embed script in your HTML file. Simply place the following script tag in either the <head> or <body> section of your HTML file:

<script src="https://chat.direqt.ai/embed.js?pubId=YOUR_PUBLISHER_ID" async></script>

If you plan on implementing multiple instances of Direqt on the same page, it is recommended to add the script to the <head> of your document. Otherwise, you can add it before the embed container in step 2.

Note

Remember to replace YOUR_PUBLISHER_ID with your actual publisher ID.

Adding The Container

Next, you need to add the embed container to your HTML file. This container specifies where the Direqt chat will be displayed on your webpage. Here's an example of how to add the container:

<ins
  style="display: block; width: 100%"
  class="direqt-embed"
  data-bot-id="YOUR_BOT_ID"
></ins>

Note

Remember to replace YOUR_BOT_ID with your actual bot ID.

Configuring the Embed

To customize the embed, you can add and modify certain attributes of the <ins> element:

attribute accepted values description
data-bot-id YOUR_BOT_ID Specify the ID of the bot you want to embed. Replace YOUR_BOT_ID with the actual bot ID provided by Direqt.
data-layout (optional) expand, fixed, faq, overlay, hidden Specify how Direqt chat will be displayed. If nothing is set, defaults to expand.
  • expand - begins at the height of the first bubble sent and can be expanded to 400px when user wants to fully interact.
  • fixed - takes up exactly 400px and cannot be shrunk.
  • faq - displays smart prompts as a list of clickable frequently asked questions. After user clicks a question it's sent as a message and the chat experience continues as it normally would in the expand layout.
  • overlay - fixes the chat to the bottom right of the page and displays the bot's logo as an inbox icon. As new messages come in a speech bubble and notification alerts the user. Clicking the inbox opens a chat to the bottom of the page.
  • hidden - hides the chat after initial load but before displaying. Useful for if you want the embed to send a page's information to the backend without having the widget shown on the page.
data-disable-ui-extensions true, false Dictate whether you'd like to disable the extended UI behaviors for quizzes & polls.
data-story-id (optional) YOUR_STORY_ID, auto Specify if you want Direqt chat to begin within the context of a specific story. Accepts a storyId from the Direqt console or auto, which uses the page's URL to detect the story. Note that if you use this attribute and the iframe cannot find a story using the provided information, Direqt chat will hide itself.
data-start-hint (optional) quiz, daily-quiz, poll Tells the Direqt widget to start a conversation in a specific context. quiz will start a story quiz (if story-id is provided and valid), and daily-quiz will start a daily quiz. poll starts the conversation by selecting a poll associated with a recent story (if story-id is present), or a recent poll (if no story-id is provided). Quizzes and Polls must be configured in the Direqt console for these features to work.
data-strict (optional) false The Direqt widget will hide itself if data-start-hint is provided but the conditions cannot be met, such as when a quiz is requested but the story cannot be found. By setting data-strict to false this behavior is changed so instead of hiding itself, the bot will match the request as closely as possible.
data-gtm (optional) true Set to true to specify that you want you want Direqt chat to pass events to Google Tag Manager. The following are some key events sent by Direqt to GTM:
  • direqt_init when a direqt instance has been found and the initialization process has started.
  • direqt_load_success when the an instance of direqt has been successfully added to the page.
  • direqt_load_failure in the case something in the process of loading your chatbot fails and the embed hides itself. The step in which initialization failed is logged as the event's value.
  • direqt_seen when the direqt instance has entered the user's viewport.
  • direqt_interaction when a user interacts with anything within the chat.
  • direqt_sentText when a user sends a text message to the bot, including smart prompts.
  • direqt_sentSuggestion when a user clicks and sends a suggestion message.
  • direqt_sentAction when a user sends an action event, such as opening a URL suggestion.

Feel free to modify the provided markup and customize it according to your specific requirements. If you need to embed multiple chatbots on the same page, you can add additional <ins> elements.

Initializing Dynamically Inserted Containers (Optional)

Direqt embed containers are typically populated automatically upon page load. However, if you're dynamically adding an embed container, you can trigger the initialization process manually by invoking the initDireqt() function.