Conversations
for c in m.comments():
convo = m.conversation_for(c)
if convo:
said = [x["body"] for x in m.messages(convo) if x["direction"] == "in"]Pass the last at you saw as since to get only what is new.
- Needs in machine.yaml
data: [conversations:read]- Returns
[{"id", "direction" ("in" or "out"), "sent_by", "body", "at"}].
m.comments
Recent comments on the business's Instagram account.
m.comments(*, post=None, since=None)newest = m.comments(since=m.setting("comments_since"))
if newest:
m.save_setting("comments_since", newest[-1]["at"])Or on one post. since is an at a previous call returned, so a poll doesn't re-read everything. Replies under a comment and the account's own comments are left out. Pass one back, unchanged, to m.reply_to_comment. Never raises.
- Needs in machine.yaml
data: [conversations:read]- Returns
[{"id", "post", "account", "space", "text", "author": {"id", "username", "name"}, "at"}].
m.conversation_for
The DM conversation with whoever wrote a comment.
m.conversation_for(comment)convos = [m.conversation_for(c) for c in m.comments()]It appears once they write back or tap a quick reply. Matched on their account, never a display name. Never raises.
- Needs in machine.yaml
data: [conversations:read]- Returns
- The conversation's id, or None until there is one.
m.follows_you
Does the person on a conversation follow the account?
m.follows_you(conversation)for c in m.comments():
convo = m.conversation_for(c)
if convo and m.follows_you(convo) is False:
m.save_setting("ask_to_follow", convo)None when Instagram didn't say, which is common: decide what None means for your machine.
- Needs in machine.yaml
data: [conversations:read]- Returns
- True, False or None.
m.claim
Take charge of a conversation in the inbox.
m.claim(conversation, *, title, days=7, trigger=None)for c in m.comments():
convo = m.conversation_for(c)
if convo and m.claim(convo, title="Quote Follow Up", days=7):
m.release(convo, note="Asked about a quote; a person should answer.")While the machine holds it, the inbox doesn't draft it, greet it or count it as waiting on a person, and shows it as handled by title. It is never taken from another machine. Calling again renews it, and it lets go by itself after days (at most 30). Once a person on the team replied and took it over, no machine claims it again.
- Needs in machine.yaml
data: [conversations:write]- Returns
- True if this machine holds it.
for c in m.comments():
convo = m.conversation_for(c)
if convo:
m.release(convo)With a note, it is handed back to the team, and the note is shown to whoever answers it. Without one, the machine simply finished.
- Needs in machine.yaml
data: [conversations:write]- Returns
- True or False.