dcsan / WeChatCookbook

tips on making wechat apps
0 stars 0 forks source link

how to send multiple messages #2

Open dcsan opened 9 years ago

dcsan commented 9 years ago

3) can you send multiple replies

For wechat public account when user sends a message the server (account) can reply to that message

but can you send more than one message? eg:

user: hello app: hi, how are you? app: we have some new things today! app: would you like to look?

or is it limited to just one reply per user question?

The wechat bot has a “menu” option but I’m not sure if that actually sends multiple responses.

https://github.com/node-webot/wechat/issues/189

dcsan commented 9 years ago

based on this question https://github.com/node-webot/wechat/issues/189#issuecomment-139777364

the WeChat docs here show a type of JSON for sending messages.

however the node-webot api uses a reply() method.

https://github.com/node-webot/wechat/issues/189#issuecomment-139777364

how to extract an auth token from node-webot payload and then use that to send a follow-on message?

dcsan commented 9 years ago

OK so this should be possible with the API http://admin.wechat.com/wiki/index.php?title=Customer_Service_Messages

The developer can then POST a JSON packet to the user unlimited times by calling this pushing message API within a given period, which is currently 48 hours

I setup a simple method to send messages, but I am getting

{ errcode: 48001, errmsg: 'api unauthorized hint: [IXFNoa0293age6]' } }

http://admin.wechat.com/wiki/index.php?title=Return_Codes

@klbjlabs Can you see if you can get it to work?

steps:

dcsan commented 9 years ago

image

klbjlabs commented 9 years ago

Looks like your Offical account is not enough permission. I remember that there are some different types of Offical account, which have different permissions.

klbjlabs commented 9 years ago

image

Is that your openId?

image

image

dcsan commented 9 years ago

ok that makes sense.

dcsan commented 8 years ago

enabling the debug accounts

image

I can get to this:

image

I'm not sure if 客服接口 means sending messages with WeChat admin panel, or sending from the API.

klbjlabs commented 8 years ago

I think it's means both of API & admin panel.

dcsan commented 8 years ago

docs: http://admin.wechat.com/wiki/index.php?title=Customer_Service_Messages

{ url: 'https://api.wechat.com/cgi-bin/message/custom/send?access_token=xxxx', method: 'POST', json: true, headers: { 'content-type': 'application/json' }, body: '{"touser":"UUUUU","msgtype":"text","text":{"content":"testing"}}' }

Tue, 29 Sep 2015 16:53:55 GMT mbot:WeChatAdapter simple post err> null Tue, 29 Sep 2015 16:53:55 GMT mbot:WeChatAdapter simple post res.body { errcode: 40003, errmsg: 'invalid openid hint: [xxxx]' }

I'm using test account to send a message and getting invalid openid error.

I'm using the message.FromUserName from the original incoming message to reply to. this user is "whitelisted" in the panel

are there some other steps to get a user's true openID?

dcsan commented 8 years ago

http://admin.wechat.com/wiki/index.php?title=Getting_Started

When a user sends a message to an official account, the ID provided to the official account is the OpenID for the user. This OpenID is generated via encryption. For each official account, each user will be represented by a unique OpenID.

so the openID should what we get in the incoming message >.<