Answer with your own AI
Autoobot carries the messages both ways and keeps the channels safe; your model writes every word.
How it works
- Set the asset’s automatic replies to Your system (or
PATCH /api/assets/{id}/automationwith{"mode": "external"}): Autoobot sends nothing automatic there. - A person writes: your webhook gets
message.receivedorcomment.received. - Your server answers the webhook at once (2xx), then asks your model.
- You send the reply:
POST /api/conversations/{id}/messages, with the event’s id asIdempotency-Key. - Autoobot sends it at the channel’s pace; your team sees it in the inbox, marked «via API».
Example server
import express from 'express';
import { verify } from './verify.js'; // see Webhooks › Check the signature
const app = express();
app.post('/autoobot', express.raw({ type: 'application/json' }), async (req, res) => {
if (!verify(req.body.toString(), req.get('Autoobot-Signature') || '', process.env.AUTOOBOT_WEBHOOK_SECRET)) return res.sendStatus(401);
res.sendStatus(200); // answer at once; the event is sent once
const event = JSON.parse(req.body);
if (event.type !== 'message.received' && event.type !== 'comment.received') return;
const reply = await myModel({ text: event.data.message.text, person: event.data.conversation.contact.name, channel: event.data.asset.channel });
const response = await fetch(`https://autoobot.com/api/conversations/${event.data.conversation.id}/messages`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.AUTOOBOT_KEY}`, 'Content-Type': 'application/json', 'Idempotency-Key': event.id },
body: JSON.stringify({ text: reply }),
});
if (response.status === 409) return; // a person on the team took over: let them answer
});
app.listen(3000);What to do when…
| Answer | Meaning | Do |
|---|---|---|
409 conversation_paused | A person on your team stepped in. | Stay quiet; the conversation.handoff event tells when the bot resumes. |
422 outside_reply_window | The person last wrote too long ago. | Wait for them to write again. |
402 reply_limit_reached | The asset’s package has no replies left. | Make it Unlimited in Autoobot › Billing. |
429 rate_limited | Over 5 requests a second. | Wait for Retry-After and send again with the same Idempotency-Key. |
Give your model the conversation, not only the last message:
GET /api/conversations/{id}/messages?limit=20. Contacts’ fields and labels (GET /api/contacts/{id}) help it personalise.