If your product has a GraphQL API, your bot can use it. Paste the address and a token, and OrbContext reads the API and turns each query into a lookup the bot can run, such as an order's status or what is in stock. Each mutation becomes an action the bot can offer, and the visitor confirms it before anything changes.
Connect your API
Open Actions and choose GraphQL API
In the dashboard, open your bot, choose Actions, and under Add a connection choose GraphQL API.
Start from a platform, or paste your own address
Start from fills in the address and how the token is sent for Shopify Storefront, GitHub, Contentful, Saleor, WordPress (WPGraphQL) and Strapi, with a note on what to put in each blank. It only fills in the form: you can change anything, and every other GraphQL API works with Any GraphQL API. Replace the parts in
{braces}with your own before you connect.Say what it is for, and paste the address
Write one sentence about what the API holds, for example "Our store: products, stock and order status." The bot reads it, and each query's own description, to decide which lookup fits a question. The address starts with
https://and usually ends in/graphql.Add a token if the API needs one
Tick This API needs a token and paste it. Most APIs expect it as
Authorization: Bearer, which is the default. If yours uses its own header, such asX-Shopify-Storefront-Access-Token, choose A custom header and type its name (it starts withX-). The token is stored encrypted and never shown again. Other fixed values your API wants on every request can be added as variables, which are hidden the same way.Choose Connect
OrbContext reads the API's schema and lists its queries and mutations. If the API has twenty queries or fewer, they all start switched on. A larger API starts with everything off so you can choose. Mutations always start off.
You should see: a line such as "Connected: 6 queries and 3 mutations", then your new connection with the tools that are switched on.
Choose what the bot can use
Your connection lists the tools that are switched on. Choose Add tool to search the rest and switch one on. You can show all of them, only lookups (queries), or only mutations. The bot can only use tools that are switched on.
Each tool has Test and Configure. Configure opens these settings:
| Setting | What it does |
|---|---|
Use this tool | Whether the bot may use it at all. A tool that is off is never offered. |
Fields to fetch | Lookups only. Choose Edit fields to change what the bot receives (see below). |
Show a result card | Lookups only. Show the visitor the result as a list or a record, as well as in the bot’s words. |
Customize result | Lookups only. Lay the card out as a product, with your own choice of fields (see below). |
Ask for confirmation | In Advanced settings. For a lookup, show the visitor a card and wait for their OK before it runs. A mutation always asks. |
Treat as a read-only lookup | In Advanced settings, mutations only. Some APIs use a mutation for something that only reads, such as a search. Turn this on only if the mutation never changes data. It then behaves like a lookup. |
Treat this as a source of truth | In Advanced settings. Compare what this lookup returns with your documents, and flag it when they disagree. |
Hide sensitive fields from the bot | In Advanced settings. The bot normally sees everything a lookup returns. Turn this on to replace passwords, tokens, keys and similar fields with [hidden] before the bot sees them, so it cannot repeat them. Leave it off if a later step needs one of them. |
Connection settings, on the connection itself, holds the address, the schema, instructions for the bot, the hourly call limit, and buttons to pause or delete the connection.
Choose the fields it fetches
A lookup fetches a sensible set of fields by default: the simple ones, plus one level of related items. To change that, choose Edit fields on a query and write the fields you want in braces. Nested items get their own braces.
{ number status total customer { name } }What you write here is everything the bot can ever see from this lookup, so leave out anything it shouldn't repeat. OrbContext checks it against your schema when you save and tells you which field it doesn't recognise. Use the default fields puts the original set back.
Try a tool before the bot does
Choose Test on any tool. Fill in its inputs (the ones marked with a star are required), then Run test. You see exactly what your API returned, so you can check the fields and the token before a visitor asks. A test doesn't use credits and doesn't appear in any conversation.
Show a lookup as a product card
A result card normally lays itself out from the data. For a product lookup you can choose the layout yourself. Open Configure on the lookup and choose Customize result, then Product details. Tell it which fields hold the title, description, image, price, currency, compare-at price, availability and product page. Only the title is required.
The preview uses the reply from your last Test. You can also paste a reply or choose Use sample product. Check the card at desktop and mobile widths, then choose Publish result. The sample is not saved, only which fields go where. Visitors see the new card the next time the lookup runs, in the playground and the widget. Automatic goes back to the inferred layout.
Images and links must be https. A price is shown only with a valid currency code, such as USD or INR. If the title is missing from a reply, no card is shown. Cards never appear in REST API answers.
What visitors can do on your website
| On your website | |
|---|---|
Queries | Only if you turn on Allow unverified website lookups in Connection settings. Use it only for information that is safe to show anyone, such as opening hours or availability. Otherwise they work in the playground only. |
Mutations | Never for an unverified visitor. Tick “Let website visitors verify with an emailed code” when you connect: every mutation then asks the visitor to verify, then shows a confirmation card, and runs only after they confirm. Without it, mutations work in the playground only. |
A lookup can ask for verification too. With verification set up, turn on Require visitor verification in its advanced settings for personal information, such as an order's details. Turn it off to switch it back.
When your API changes
Open Connection settings and choose Refresh schema after you change your API. OrbContext reads it again and keeps your choices for everything that still exists. A new query starts off. If a tool you had on no longer fits, because a field it used was removed, it is switched off and marked Needs review, so it can't fail in front of a visitor. Choose Review and turn it on again to use the new fields. If you pasted the schema, choose Replace schema and paste the new one.
Good to know
| Limit | Detail |
|---|---|
Address | A public https address. Private and internal addresses are refused. |
Subscriptions | Not supported. Queries and mutations only. |
Big APIs | Up to 400 queries and mutations are listed, queries first. Each call waits up to 15 seconds and reads up to 2 MB of the answer. |
Calls an hour | Set a limit when you connect, or later with Change limit. It is the most calls visitors’ questions may make to your API in an hour. Past it, calls are not made, they are not charged, and the bot answers from what it already knows. It keeps your own API from running out of its quota. Your tests from the dashboard do not count. |
Retries | A lookup that hits a brief error (502, 503, 504) is tried once more. A mutation is never sent twice, so if the answer is lost the run is marked unknown and nothing is repeated. |
Errors in the answer | GraphQL reports many errors inside a normal response. OrbContext reads them: partial data is used with a note, and a refusal is passed to the bot as a refusal. |
Rejected token | If your API says the token is no longer valid, the connection pauses and the bot stops using it until you reconnect with a new token. |